Skip to content

Conversation

@snowystinger
Copy link
Member

@snowystinger snowystinger commented Oct 10, 2025

Closes

Updates to the latest eslint plugin for react to use the compiler. The main transforms I applied are detailed in this issue Confusion with useEffectEvent lint rules

Note, I had to use useLayoutEffect to get the synchronous behaviour in React 16 and 17 so that events fired back to back would still have the effect run between them. (for example,
This could also be accomplished with flushSync, but then that takes us out of concurrent mode.

This PR mostly focuses on react-hooks/rules-of-hooks

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

🧢 Your Project:

@rspbot
Copy link

rspbot commented Oct 10, 2025

@devongovett
Copy link
Member

The linter is probably correct about the errors with our useEffectEvent. We should try to solve those instead of renaming the hook.

@snowystinger
Copy link
Member Author

Darn, just a gut feeling? Or is there something in particular you're worried about? Trying to understand the rules better

@devongovett
Copy link
Member

Child effects run before parents so the function won't necessarily be bound yet if you pass one down

@snowystinger
Copy link
Member Author

Child effects run before parents so the function won't necessarily be bound yet if you pass one down

Ok, so nothing beyond what I noted in the description, which we don't currently violate from what I saw. Will explore some fixes this week.

@rspbot
Copy link

rspbot commented Oct 13, 2025

@rspbot
Copy link

rspbot commented Oct 15, 2025

@rspbot
Copy link

rspbot commented Oct 15, 2025

removeGlobalListener(window, 'pointerup', onPointerUp, false);
removeGlobalListener(window, 'pointercancel', onPointerUp, false);
};
} else if (pointerDown === 'mouse' && process.env.NODE_ENV === 'test') {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically these can only happen during test environment, but i've added here so that the dead code remover knows to get rid of it

@rspbot
Copy link

rspbot commented Oct 17, 2025

Copy link
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have to come back to the usePress change (I think it is mainly just code moving around), but my comment on the useAutocomplete change encompasses my main thoughts about the change, primarily a slight concern around move away from using useEffectEvent since they are scoped to useEffectEvents/useEffects within the same component by the linter, but that means things that used to be returned from various hooks are now reactive again. Maybe a nothing burger

@rspbot
Copy link

rspbot commented Oct 20, 2025

@rspbot
Copy link

rspbot commented Oct 23, 2025

@rspbot
Copy link

rspbot commented Oct 23, 2025

## API Changes

@react-aria/utils

/@react-aria/utils:useUpdateEffect

 useUpdateEffect {
-  effect: EffectCallback
+  cb: EffectCallback
   dependencies: Array<any>
   returnVal: undefined
 }

@snowystinger snowystinger added this pull request to the merge queue Oct 23, 2025
Merged via the queue into main with commit a0d9474 Oct 23, 2025
32 checks passed
@snowystinger snowystinger deleted the update-eslint-plugin-react-hooks branch October 23, 2025 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants